using UnityGameFramework.Runtime;

namespace StarForce.Hotfix
{
    /// <summary>
    /// 热更入口
    /// </summary>
    public class HotfixGameEntry
    {
        /// <summary>
        /// 有限状态机
        /// </summary>
        public static FsmManager Fsm
        {
            get;
            private set;
        } 
        
        /// <summary>
        /// 用户管理
        /// </summary>
        public static UserDataManager UserData
        {
            get;
            private set;
        }   
        
        /// <summary>
        /// 事件管理
        /// </summary>
        public static EventManager Event
        {
            get;
            private set;
        }
        
        
        /// <summary>
        /// 流程
        /// </summary>
        public static ProcedureManager Procedure
        {
            get;
            private set;
        }   

//        private static ProcedureHotfixBase[] procedures  = new ProcedureHotfixBase[]
//        { 
//              new ProcedureHotfixLaunch()
//            , new ProcedureHotfixChangeScene()
//            , new ProcedureHotfixMenu()
//            , new ProcedureHotfixMain()
//        };
        
        public static void Start()
        {
            Fsm = new FsmManager();
            Procedure = new ProcedureManager();
            Event=new EventManager();
            UserData=new UserDataManager();

            Procedure.Initialize(Fsm, new ProcedureHotfixLaunch()
                , new ProcedureHotfixChangeScene()
                , new ProcedureHotfixMenu()
                , new ProcedureHotfixMain());

            //开始热更新层入口流程
            Procedure.StartProcedure<ProcedureHotfixLaunch>();
        }
        
        
        public static void Update(float elapseSeconds, float realElapseSeconds)
        {
            Fsm.Update(elapseSeconds, realElapseSeconds);
            Event.Update(elapseSeconds, realElapseSeconds);
//            Task.Update(elapseSeconds, realElapseSeconds);
        }

        public static void Shutdown()
        {
            Procedure.Shutdown();
            Fsm.Shutdown();
            Event.Shutdown();
//            ETNetwork.Shutdown();
        }
    }
}